import { uploadFile } from '@/utils/file';
import { Button } from 'antd';

const FileUpload = () => {
  const [fileList, setFileList] = useState<File[]>([]);
  const onProgress = (progress: number) => {
    console.log(progress);
  };
  const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    if (!e.target.files) return;
    const file = e.target.files?.[0];
    if (file) {
      setFileList([file]);
    }
  };
  const onHandleClick = async () => {
    console.log(fileList);
    const result = uploadFile(fileList[0], 2, 3, 1000, onProgress);
    console.log(result);
  };
  return (
    <>
      <input type="file" onChange={onChange} />
      <Button onClick={onHandleClick}>上传</Button>1
    </>
  );
};
export default FileUpload;
